
<%@ page isELIgnored="false" contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>登录</title>

    <% String contextPath = request.getContextPath(); %>

    <script src="<%=contextPath%>/js/jquery.min.js" type="text/javascript" />



    <style>
        body{
            margin:0 auto;
            text-align:center
        }
        .form-box{
            display: flex;
            flex-direction: column;
        }
    </style>

    <script type="text/javascript">
    </script>
    <script type="text/javascript">

        $(document).ready(function(){
            console.log("login.jsp");
        });

        //通过ajax实现
        function login() {
            var username = $("#username").val();
            var password = $("#password").val();

            $.ajax({
                url: 'http://localhost:8080/sss/user/login',
                type: 'POST',
                data: {username:username, password:password},
                contentType: 'application/json;charset=utf-8',
                dataType: 'json',
                success: function (data) {
                    console.log(data);
                }
            })
        }
    </script>

</head>
<body>

    <div class="form-box">
        <form id="login_form" action="/sss/user/login" method="post">
            <div>
                <label>用户名</label>
                <input type="text" id="username" name="username">
            </div>
            <div>
                <label>密码</label>
                <input type="password" id="password" name="password" />
                <c:if test="${ sessionScope.state=='-1' }">
                    <label id="login_msg" style="color: red;display: block">用户名或者密码错误</label>
                </c:if>
            </div>
            <input type="submit" value="登录">
        </form>

    </div>
</body>
</html>
